#include <iostream>
using namespace std;

int main(int argc, const char *argv[]){
    string s1 = "abcdefg";
    // 读值
    cout << s1[0] << endl; // a
    cout << s1.at(1) << endl; // b
    // 赋值
    s1[2] = 'C';
    s1.at(3) = 'D';
    // 遍历
    for(int i = 0; i < s1.size(); i++){
        cout << s1[i];
    }
    cout << endl;
    
    for(int i = 0; i < s1.size(); i++){
        cout << s1.at(i);
    }
    cout << endl;

    return 0;
}